/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fastmerge;

import core.crypto.integrity.p2m.MemoryStream;
import core.crypto.integrity.p2m.MemoryStream.OutToMemory;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 *
 * @author vinicius.rodrigues
 */
public class Main {

    public static void main(String[] args) throws IOException{
        MemoryStream memoryStream = new MemoryStream(Short.MAX_VALUE);
        OutputStream out = memoryStream.new OutToMemory();
        InputStream in = new FileInputStream("c:\\data.bin");
        int l = 0;
        byte[] buffer = new byte[8192];
        long begin = System.currentTimeMillis();
        while((l = in.read(buffer)) != -1){
            out.write(buffer);
        }
        long end = System.currentTimeMillis();

        /*
        OutputStream out = new FileOutputStream("c:\\data.bin");
        long begin = System.currentTimeMillis();
        for(int i = 0; i < 12800;i++){
            out.write(new byte[8192]);
        }
        long end = System.currentTimeMillis();
         */
        System.out.println("Processado em : " + (end - begin) );
    }
    
}
